home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / RoboticInvaders.dxr / 00004_Engine Scripts.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  7.7 KB  |  224 lines

  1. global playerShipSO, armorSO, pBulletSO, eBulletSO, enemySO, enemyData, fleetMovementData, playerData, pBulletData, eBulletData, armorData, playerlevel, totalScore, playerScore, activeBullets, playerintro
  2.  
  3. on runBugs
  4.   global targetLocationList, deathDelay, frameNumber, frameDelay, totalBugs, accuracyRating, lowestRank, swoopDelay, targetlocation, selectedCraft, homein
  5.   if frameDelay <= 0 then
  6.     frameDelay = 5
  7.     if frameNumber < 3 then
  8.       frameNumber = frameNumber + 1
  9.     else
  10.       frameNumber = 1
  11.     end if
  12.   else
  13.     frameDelay = frameDelay - 1
  14.   end if
  15.   case fleetMovementData[2] of
  16.     #left:
  17.       if fleetMovementData[1][1] < 0 then
  18.         fleetMovementData[2] = #right
  19.         fleetMovementData[1][2] = fleetMovementData[1][2] + 5
  20.       end if
  21.     #right:
  22.       if fleetMovementData[1][1] > 180 then
  23.         fleetMovementData[2] = #left
  24.         fleetMovementData[1][2] = fleetMovementData[1][2] + 5
  25.       end if
  26.   end case
  27.   case fleetMovementData[2] of
  28.     #left:
  29.       fleetMovementData[1][1] = fleetMovementData[1][1] - 2
  30.     #right:
  31.       fleetMovementData[1][1] = fleetMovementData[1][1] + 2
  32.   end case
  33.   validLocs = []
  34.   totalBugs = 0
  35.   lowestRank = 0
  36.   repeat with wBug = 1 to count(enemyData)
  37.     if enemyData[wBug][1] = 1 then
  38.       if findDistance(playerData[2], enemyData[wBug][5]) <= 15 then
  39.         addparticle(playerData[2], 0, 1)
  40.         playSound("Player Death SFX", 3)
  41.         playerData[1] = 0
  42.       end if
  43.       if homein = 1 then
  44.       else
  45.       end if
  46.       if enemyData[wBug][6] <> 0 then
  47.         targetDestination = targetLocationList
  48.         case enemyData[wBug][7] of
  49.           2:
  50.             targetDestination = targetDestination + point(-50, -15)
  51.           3:
  52.             targetDestination = targetDestination + point(50, -15)
  53.         end case
  54.       else
  55.         targetDestination = enemyData[wBug][4] + fleetMovementData[1]
  56.       end if
  57.       moveAim = findAngle(enemyData[wBug][5], targetDestination)
  58.       moveDist = findDistance(enemyData[wBug][5], targetDestination)
  59.       if moveDist > 8 then
  60.         moveDist = 8
  61.       end if
  62.       wSprite = wBug + enemySO - 1
  63.       locY = cos(moveAim * PI / 180) * -moveDist
  64.       locX = sin(moveAim * PI / 180) * moveDist
  65.       enemyData[wBug][5] = enemyData[wBug][5] + point(locX, locY)
  66.       repeat with wBullet = 1 to count(pBulletData)
  67.         if pBulletData[wBullet][1] = 1 then
  68.           if findDistance(enemyData[wBug][5], pBulletData[wBullet][2]) <= 20 then
  69.             accuracyRating[1] = accuracyRating[1] + 1
  70.             pBulletData[wBullet][1] = 0
  71.             enemyData[wBug][3] = enemyData[wBug][3] + 1
  72.             set the loc of sprite (pBulletSO + wBullet - 1) to point(-50, -50)
  73.           end if
  74.         end if
  75.       end repeat
  76.       if enemyData[wBug][3] >= 1 then
  77.         playerScore = playerScore + (enemyData[wBug][2] * 15)
  78.         member("Score display").text = string(totalScore + playerScore)
  79.         if enemyData[wBug][6] = 0 then
  80.         else
  81.         end if
  82.         addparticle(enemyData[wBug][5], 0, 1)
  83.         enemyData[wBug][1] = 0
  84.         set the loc of sprite wSprite to point(-50, -50)
  85.         next repeat
  86.       end if
  87.       set the loc of sprite wSprite to enemyData[wBug][5]
  88.       if (enemyData[wBug][4] + fleetMovementData[1])[2] > lowestRank then
  89.         lowestRank = (enemyData[wBug][4] + fleetMovementData[1])[2]
  90.       end if
  91.       set the member of sprite wSprite to "Robot" & ["1", "2", "3", "4"][enemyData[wBug][2]] & ["a", "b", "c", "d"][frameNumber]
  92.       add(validLocs, enemyData[wBug][5])
  93.       totalBugs = totalBugs + 1
  94.     end if
  95.   end repeat
  96.   if (deathDelay = 40) and (playerintro = 0) then
  97.     fleetMovementData[3] = fleetMovementData[3] - 1
  98.     if count(validLocs) > 0 then
  99.       if fleetMovementData[3] < 0 then
  100.         fleetMovementData[3] = [20, 15, 10, 8, 6][playerlevel] + random(10)
  101.         shootLoc = validLocs[random(count(validLocs))]
  102.         addEBullet(shootLoc, 6, random(10) + 175)
  103.       end if
  104.     end if
  105.   else
  106.   end if
  107. end
  108.  
  109. on updateArmors
  110.   totalArmors = 4
  111.   repeat with wArmor = 1 to totalArmors
  112.     wSprite = armorSO + wArmor - 1
  113.     rBit = armorData[wArmor][1]
  114.     if rBit = 0 then
  115.       sprite(wSprite).visible = 0
  116.       next repeat
  117.     end if
  118.     set the member of sprite wSprite to "Armor " & string(rBit)
  119.   end repeat
  120. end
  121.  
  122. on addBullet spawnloc, spawnSpeed, spawnAim
  123.   validSlot = 0
  124.   repeat with wSlot = 1 to count(pBulletData)
  125.     if (validSlot = 0) and (pBulletData[wSlot][1] = 0) then
  126.       validSlot = wSlot
  127.     end if
  128.   end repeat
  129.   if validSlot <> 0 then
  130.     pBulletData[validSlot] = [1, spawnloc, spawnSpeed, spawnAim]
  131.     playSound("Player Laser SFX", 4)
  132.   end if
  133. end
  134.  
  135. on addEBullet spawnloc, spawnSpeed, spawnAim
  136.   validSlot = 0
  137.   repeat with wSlot = 1 to count(eBulletData)
  138.     if (validSlot = 0) and (eBulletData[wSlot][1] = 0) then
  139.       validSlot = wSlot
  140.     end if
  141.   end repeat
  142.   if validSlot <> 0 then
  143.     eBulletData[validSlot] = [1, spawnloc, spawnSpeed, spawnAim]
  144.     playSound("Enemy Laser SFX", 5)
  145.   end if
  146. end
  147.  
  148. on runPBullets
  149.   activeBullets = 0
  150.   repeat with wBullet = 1 to count(pBulletData)
  151.     if pBulletData[wBullet][1] = 1 then
  152.       wSprite = pBulletSO + wBullet - 1
  153.       bLoc = pBulletData[wBullet][2]
  154.       validArmor = 0
  155.       repeat with vBlock = 1 to count(armorData)
  156.         if (validArmor = 0) and inside(bLoc, armorData[vBlock][3]) and (armorData[vBlock][1] > 0) then
  157.           validArmor = vBlock
  158.         end if
  159.       end repeat
  160.       if (bLoc[1] < 0) or (bLoc[1] > 580) or (bLoc[2] < 0) or (bLoc[2] > 440) then
  161.         pBulletData[wBullet][1] = 0
  162.         set the loc of sprite wSprite to point(-50, -50)
  163.         next repeat
  164.       end if
  165.       if validArmor <> 0 then
  166.         addparticle(bLoc, 0, 2)
  167.         armorData[validArmor][1] = armorData[validArmor][1] - 1
  168.         pBulletData[wBullet][1] = 0
  169.         set the loc of sprite wSprite to point(-50, -50)
  170.         playSound("Impact Blockers SFX", 6)
  171.         next repeat
  172.       end if
  173.       tASpeed = pBulletData[wBullet][3]
  174.       tAim = pBulletData[wBullet][4]
  175.       locY = cos(tAim * PI / 180) * -tASpeed
  176.       locX = sin(tAim * PI / 180) * tASpeed
  177.       pBulletData[wBullet][2] = pBulletData[wBullet][2] + point(locX, locY)
  178.       set the loc of sprite wSprite to pBulletData[wBullet][2]
  179.       activeBullets = activeBullets + 1
  180.     end if
  181.   end repeat
  182. end
  183.  
  184. on runEBullets
  185.   repeat with wBullet = 1 to count(eBulletData)
  186.     if eBulletData[wBullet][1] = 1 then
  187.       wSprite = eBulletSO + wBullet - 1
  188.       bLoc = eBulletData[wBullet][2]
  189.       validArmor = 0
  190.       repeat with vBlock = 1 to count(armorData)
  191.         if (validArmor = 0) and inside(bLoc, armorData[vBlock][3]) and (armorData[vBlock][1] > 0) then
  192.           validArmor = vBlock
  193.         end if
  194.       end repeat
  195.       if (findDistance(playerData[2], eBulletData[wBullet][2]) <= 15) and (playerData[1] = 1) then
  196.         eBulletData[wBullet][1] = 0
  197.         addparticle(playerData[2], 0, 1)
  198.         set the loc of sprite wSprite to point(-50, -50)
  199.         playSound("Player Death SFX", 3)
  200.         playerData[1] = 0
  201.         next repeat
  202.       end if
  203.       if (bLoc[1] < 0) or (bLoc[1] > 580) or (bLoc[2] < 0) or (bLoc[2] > 440) then
  204.         eBulletData[wBullet][1] = 0
  205.         set the loc of sprite wSprite to point(-50, -50)
  206.         next repeat
  207.       end if
  208.       if validArmor <> 0 then
  209.         armorData[validArmor][1] = armorData[validArmor][1] - 1
  210.         eBulletData[wBullet][1] = 0
  211.         set the loc of sprite wSprite to point(-50, -50)
  212.         playSound("Impact Blockers SFX", 6)
  213.         next repeat
  214.       end if
  215.       tASpeed = eBulletData[wBullet][3]
  216.       tAim = eBulletData[wBullet][4]
  217.       locY = cos(tAim * PI / 180) * -tASpeed
  218.       locX = sin(tAim * PI / 180) * tASpeed
  219.       eBulletData[wBullet][2] = eBulletData[wBullet][2] + point(locX, locY)
  220.       set the loc of sprite wSprite to eBulletData[wBullet][2]
  221.     end if
  222.   end repeat
  223. end
  224.